package com.qidian.mes.controller;

import com.qidian.mes.pojo.WorkOrder;
import com.qidian.mes.service.WorkOrderService;
import com.qidian.mes.util.pojo.MESResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



@RestController
@RequestMapping("/workOrder")
@CrossOrigin
public class WorkOrderController {
    @Autowired
    private WorkOrderService workOrderService;

    /**
     * 获取全部数据
     * @param workOrder
     * @return
     */
    @GetMapping("/list")
    public MESResult list(WorkOrder workOrder) {
        return workOrderService.list(workOrder);
    }
    /**
     * 获取全部数据,树类型
     *
     * @return
     */
    @GetMapping("/listTree")
    public MESResult listTree() {
        return workOrderService.selectAll();
    }
    @GetMapping("/get")
    public MESResult get(Long workOrderId){
        return workOrderService.getByWorkOrderId(workOrderId);
    }

    @PostMapping("/save")
    public MESResult save(@RequestBody WorkOrder workOrder) {
        System.out.println("========================"+workOrder);
        return workOrderService.save(workOrder);
    }

    @PutMapping("/update")
    public MESResult update(@RequestBody WorkOrder workOrder){
        System.out.println("=========================="+workOrder);
        return workOrderService.update(workOrder);
    }
    @DeleteMapping("/delete")
    public MESResult delete(Long workOrderId){
        return workOrderService.delete(workOrderId);
    }
}
